<template>
  <view class="pace-table">
    <view class="table-body">
      <view class="table-content" ref="tableContent">
        <view class="vertical-table">
          <view class="vertical-header">
            <text class="finish-time" v-if="paceData.length">完赛时间: {{ paceData[paceData.length - 1].accumulatedTime }}</text>
            <text class="average-pace" v-if="averagePace">平均配速: {{ averagePace }}</text>
          </view>
          <view 
            v-for="(row, index) in paceData" 
            :key="index"
            class="vertical-row"
            :class="{ 'row-even': index % 2 === 0 }"
          >
            <view class="vertical-cell">
              <view class="cell-content">
                <text class="cell-label">第{{ row.distance }}公里</text>
                <text class="cell-value" :class="{ 'milestone-time': row.distance % 10 === 0 }">{{ row.accumulatedTime }}</text>
              </view>
            </view>
          </view>
        </view>
      </view>
    </view>
  </view>
</template>

<script>
export default {
  name: 'PaceTable',
  props: {
    paceData: {
      type: Array,
      default: () => []
    }
  },
  computed: {
    averagePace() {
      if (!this.paceData || this.paceData.length === 0) return null;
      const lastRow = this.paceData[this.paceData.length - 1];
      return lastRow.pace;
    }
  }
};
</script>

<style>
.pace-table {
  padding: 5rpx;
  background-color: #fff;
  border-radius: 10rpx;
}

.table-content {
  padding: 5rpx;
}

.vertical-table {
  border: 1px solid #eee;
  border-radius: 8rpx;
  overflow: hidden;
}

.vertical-header {
  background-color: #f8f8f8;
  padding: 5rpx;
  font-size: 28rpx;
  font-weight: bold;
  color: #666;
  text-align: center;
  border-bottom: 1px solid #eee;
  display: flex;
  justify-content: center;
  align-items: center;
  flex-direction: column;
  gap: 2rpx;
}

.average-pace {
  font-size: 24rpx;
  color: #007AFF;
}

.vertical-row {
  padding: 4rpx;
  border-bottom: 1px solid #f5f5f5;
}

.vertical-cell {
  padding: 4rpx 8rpx;
}

.cell-content {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 10rpx;
}

.cell-label {
  font-size: 28rpx;
  font-weight: bold;
  color: #333;
  text-align: center;
}

.cell-value {
  font-size: 28rpx;
  color: #007AFF;
  font-weight: bold;
  text-align: center;
}

.milestone-time {
  color: #ff4d4f !important;
  font-weight: 900;
}
</style>